package com.itheima.three;

import java.io.PrintStream;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        try{
            //1.请求与服务端进行连接
            Socket socket=new Socket(InetAddress.getLocalHost().getHostAddress(),9999);
            //2.得到一个打印流
            PrintStream ps=new PrintStream(socket.getOutputStream());
            //3.使用扫描器输入内容
            Scanner sc=new Scanner(System.in);
            while(true){
                System.out.print("请说：");
                String msg=sc.nextLine();
                ps.println(msg);
                ps.flush();
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
